import { createRouter, createWebHistory } from "vue-router";
import login from '@/views/Login/index.vue'
import layout from '@/views/Layout/index.vue'
import category from '@/views/Category/index.vue'
import home from '@/views/Home/index.vue'
import subCategory from '@/views/SubCatrgory/index.vue'
import detail from '@/views/Detail/index.vue'
import cartList from '@/views/CartList/index.vue'
import checkout from '@/views/Checkout/index.vue'
import pay from '@/views/Pay/index.vue'
import PayBack from "@/views/Pay/PayBack.vue";
import member from '@/views/Member/index.vue'
import UserInfo from "@/views/Member/conponents/UserInfo.vue";
import UserOrder from "@/views/Member/conponents/UserOrder.vue";

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            component: layout,
            children: [
                {
                    path: '',
                    component: home
                },
                {
                    path: 'category/:id',
                    component: category
                },
                {
                    path: 'category/sub/:id',
                    component: subCategory
                },
                {
                    path: 'detail/:id',
                    component: detail
                },
                {
                    path: 'cartList',
                    component: cartList

                },
                {
                    path: 'checkout',
                    component: checkout
                },
                {
                    path: 'pay',
                    component: pay
                },
                {
                    path: 'paycallback',
                    component: PayBack
                },
                {
                    path: 'member',
                    component: member,
                    children: [
                        {
                            path: '',
                            component: UserInfo
                        },
                        {
                            path: 'order',
                            component: UserOrder
                        }
                    ]
                }
            ]
        },
        {
            path: '/login',
            component: login
        }
    ],
    //路由行为配置
    scrollBehavior() {
        return {
            top: 0
        }
    }
})

export default router